package Chapter8;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

/**
 * Created by m.zabarylo on 10/10/2014.
 */
public class TimerDemo {

    private WebDriver driver;
    private StringBuffer verificationErros = new StringBuffer();

    @Before
    public void setUp()
    {
        driver = new ChromeDriver();
    }

    @Test
    public void testBMICalculator_Perf() throws Exception
    {
        //get the start time
        long startTime = System.currentTimeMillis();
        //open app
        driver.get("http://dl.dropbox.com/u/55228056/bmicalculator.html");
        //wait for the calculate button
        new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("Calculate")));
        //get the end time
        long endTime = System.currentTimeMillis();
        //measure total time
        long totalTime = endTime - startTime;
        System.out.println("Total page load time is" + totalTime + "milliseconds");

    }
    @After
    public void tearDown()
    {
        driver.quit();
    }
}
